def countdown(n):
      while n > 0:
            yield n
            n -= 1

generator = countdown(5) #创建生成器对象

#通过迭代器生成器获取值
print(next(generator))
print(next(generator))
print(next(generator))

#使用for循环迭代生成器
for value in generator:
      print(value)